/**
 * Created with JetBrains WebStorm.
 * User: Administrator
 * Date: 15-10-15
 * Time: 下午2:01
 * To change this template use File | Settings | File Templates.
 */
window.onload=function(){
    var guideId = $.getUrlParam('guideId');
    var url = getUrl();
    $("#aaaa").attr('href','xiedianping.html?id='+guideId+'&param=guide');
    $.jsonp({
        url: 'http://'+url+'/api/guide/comment_list-'+guideId,
        data: {},
        callbackParameter: "callback",
        success: function (data, textStatus, xOptions) {
            $.each(data.arrays,function(index,ele){
                var html0="";
                if(ele.photos!=null){

                    $.each(ele.photos,function(index,item){
                        html0 += '<img src="' + item + '" width="100"height="100"class="round-pic" alt=""> ' ;
                        //$("#photos").append(html0);
                    });
                }
                //var unixTimestamp = new Date(ele.createTime * 1000);
                //ele.createTime = unixTimestamp.toLocaleString();
                var html = '<li class="ui-border-b">' +
                    '<div class="ui-comment-list-detail clearfix">' +
                    '<div class="ui-comment-list-user clearfix">' +
                    '<div class="ui-comment-list-avatar">' +
                    '<img src="'+ele.photo+'" width="40" height="40" alt="">' +
                    '</div>' +
                    '<div class="ui-comment-list-info">' +
                    '<p>'+ele.nickName+'</p>' +
                    '<p class="ui-txt-muted">'+getTime(ele.createTime)+'</p>' +
                    '</div>' +
                    '</div>' +
                    '<div class="ui-comment-list-star">' +
                    '<span class="ui-star ui-star-'+ele.star+'"></span>'+ele.star+'分' +
                    '</div>' +
                    '</div>' +
                    '<div class="ui-comment-list-content">' +
                    ''+ele.comment+'' +
                    '</div>' +
                    '<div id="zhaopian">'+html0+'</div>'+
                    '</li> ';
                $(".ui-comment-list").append(html);

            })
        },
        error: function (xOptions, textStatus) {}
    });
    $.jsonp({
        url: 'http://'+url+'/api/guide/detail-'+guideId,
        data: {},
        callbackParameter: "callback",
        success: function (data, textStatus, xOptions) {
            $("#chat").attr("onclick","easeMobGoChat("+data.telphone+")");
            $("#telenum").attr("href","tel:"+data.telphone);
        },
        error: function (xOptions, textStatus) {}
    });
}
function onBackKeyDown() {
    jumpbyback(0,"");
}
function getTime(t){
    var nt = t*1000;
    var n = new Date(nt);
    return formatDate(n);
}
function formatDate(now)   {
    var   year=now.getFullYear();
    var   month=now.getMonth()+1;
    var   date=now.getDate();
    return   year+"-"+(month>=10?month:"0"+month)+"-"+(date>=10?date:"0"+date);
}